import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:最小的K个数
 * User: wangxin
 * Date: 2024-11-25
 * Time: 21:52
 */
public class test1 {
    public ArrayList<Integer> GetLeastNumbers_Solution (int[] input, int k) {
        // write code here
        ArrayList<Integer> res = new ArrayList<>();
        if(input != null && k > 0){
            PriorityQueue<Integer> p = new PriorityQueue<>(input.length);
            for(int i = 0;i < input.length;i++){
                p.offer(input[i]);
            }
            for(int i = 0;i < k;i++){
                res.add(p.poll());
            }
        }
        return res;
    }
}
